package main

import (
	"container/list"
	"fmt"
)

func main() {
	l := list.New()
	l.PushFront("first")
	element := l.PushBack(10)

	fmt.Println("从头部向尾布遍历")
	for i :=l.Front();i!=nil;i=i.Next(){//l.Front()与i.Next()结合，从队列头部向尾部进行遍历
		fmt.Println(i.Value)
	}
	fmt.Println("从尾部向头部遍历")

	for j := l.Back();j!=nil;j = j.Prev(){
		fmt.Println(j.Value)
	}

	fmt.Println("element句柄之前")
	l.InsertAfter("after",element)
	fmt.Println("从头部向尾布遍历")
	for i :=l.Front();i!=nil;i=i.Next(){//l.Front()与i.Next()结合，从队列头部向尾部进行遍历
		fmt.Println(i.Value)
	}

}
